package xyz.zhouzhaodong.crm.controller;


import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import xyz.zhouzhaodong.crm.service.IMaterialService;
import xyz.zhouzhaodong.crm.util.RestMessage;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * <p>
 * 材料表 前端控制器
 * </p>
 *
 * @author zhouzhaodong
 * @since 2020-06-13
 */
@RestController
@RequestMapping("/material")
public class MaterialController {

    @Resource
    IMaterialService materialService;

    /**
     * 上传单文件
     * @param file 文件
     * @param staffId 用户id
     * @param customerId 客户id
     * @return
     */
    @RequestMapping("/uploadOneFile")
    public RestMessage uploadOneFile(MultipartFile file, String staffId, String customerId) {
        return materialService.uploadOneFile(file, staffId, customerId);
    }

    /**
     * 上传多文件
     * @param files 文件
     * @param staffId 用户id
     * @param customerId 客户id
     * @return
     */
    @RequestMapping("/uploadManyFile")
    public RestMessage uploadManyFile(MultipartFile[] files, String staffId, String customerId) {
        return materialService.uploadManyFile(files, staffId, customerId);
    }

    /**
     * 下载文件
     * @param response
     * @param fileUrl
     * @return
     */
    @RequestMapping("/fileDowLoad")
    public RestMessage fileDowLoad(HttpServletResponse response, String fileUrl){
        return materialService.fileDowLoad(response, fileUrl);
    }

    /**
     * 根据用户id获取文件列表
     * @return
     */
    @RequestMapping("/findFiles")
    public RestMessage findFiles(String customerId){
        return materialService.findFiles(customerId);
    }

}
